#ifndef SEQUENCEWINDOW_H
#define SEQUENCEWINDOW_H

#include "ClickManager.h"
#include "MainWindow.h"

struct ScrollBarInfo {
	int position;
	int width;
	int range;
};

class SequenceWindow : public ClickManager<wxPanel> {
protected:
	wxTimer timer;
	int dragging;

	int lastChain;
	int lastResidue;

	int maxNameWidth;
	// First is horizontal, second is vertical.
	ScrollBarInfo scroll[2];

	int width, height;
	int fontWidth, fontHeight;
	wxFont font;
	wxFont boldFont;

	PDBManager *pdbManager;
	MainWindow *mainWindow;

	// Used in UpdateState to detect if UpdateResidueList call is needed.
	int lastActiveChain;

	//virtual void MouseMove(unsigned int flags, int x, int y) {}
	//virtual void MouseDrag(unsigned int flags, int xStart, int yStart, int xStop, int yStop) {}

	void MouseDown(unsigned int button, int clickCount, unsigned int flags, int x, int y);

	void MouseDrag(unsigned int flags, int xStart, int yStart, int xStop, int yStop);

	// Also called on fxn key up.
	void MouseUp(unsigned int button, int clickCount, unsigned int flags, int x, int y);

	void MouseWheel(unsigned int wheel, int delta, unsigned int flags, int lastActionWasWheel);

	void UpdateDragSel(int startx, int starty, int lastx, int lasty);
	void DragDone(int cancelled);

	int GetClickedResidue(int *chain, int *residue, int x, int y);

	// Pos is the 0-based index of which residue position is clicked on.
	// In the case of multiple alignments, different than GetClickedResidue().
	// Otherwise, the same, other than the lack of a return value.
	void GetClickedPosition(int *chain, int *pos, int x, int y);

	void MultipleClick(int clickCount);

	void MouseMove(unsigned int flags, int x, int y);
public:
	SequenceWindow(wxWindow *parent, MainWindow *mainWindow, PDBManager* pdbManager);
	~SequenceWindow();
	void OnSize(wxSizeEvent& evt);
	void OnTimer(wxTimerEvent &evt);
	void UpdatePDB(PDBManager *pdbManager);

	void SetScrollBars(int fullUpdate, int deltax, int deltay);

	void OnPaint(wxPaintEvent& evt);

	void UpdateDisplay();

	void ChangeSelection(int chain, int index);

	void OnScroll(wxScrollWinEvent& evt);

	DECLARE_EVENT_TABLE()
};

#endif
